package com.yaoayao.mall.activity.service.impl;

import com.yaoayao.mall.activity.service.ActivityService;
import com.yaoayao.mall.common.constant.RedisConst;
import com.yaoayao.mall.model.activity.SeckillGoods;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ActivityServiceImpl implements ActivityService {
    @Autowired
    private RedisTemplate redisTemplate;
    @Override
    public List<SeckillGoods> findAll() {
        return redisTemplate.opsForHash().values(RedisConst.SECKILL_GOODS);
    }

    @Override
    public SeckillGoods findBySkuId(Long skuId) {
        SeckillGoods seckillGoods = (SeckillGoods) redisTemplate.opsForHash().
                get(RedisConst.SECKILL_GOODS, skuId.toString());
        return seckillGoods;
    }
}
